var data2=null;
{if $Think.get.driver_id}
Load()
 data2={}
 var where_json ={};
 where_json.driver_id=['in','{$Think.get.driver_id}']
 data2.where_json=JSON.stringify(where_json)
 ajax(api.driver.list,data2,'post').done(function(res){
	Load(1)
    if(res.code==1){
        res = driverstate(res)
        for(var key in res.data[0]){
          if(key == 'head_img'|| key == 'half_body_img' || key =='insurance_img'|| key =='contract_img' || key =='id_img' ||key =='driver_license_img'||key =='residence_permit_img'){
            if(res.data[0][`${key}`]){
              $(`.${key}`).attr('src', domain+res.data[0][`${key}`])
            }else{
              $(`.${key}`).attr('src', '/assets/img/noimg.gif')
            } 
          }
      
          if (res.data[0][key]) {
            $('input[name=' + key + ']').val(res.data[0][key])                     
          }else{
            $('input[name=' + key + ']').val('暂无信息') 
          }
      }
    }
 }).fail((err)=>{
    Load(1)
    console.log(err)
    Err('请求失败')
 })

 {else/}

{/if}


layui.use('element', function () {
    var element = layui.element;
    //一些事件监听
    element.on('tab(demo)', function (data) {
      console.log(data.index)
      if (data.index == 1) {  
          if(data2){
              
        Load();
        ajax(api.driver.list,data2,'post').done(function(res) {
            console.log(res)
            // 日期区间
            laydate.render({
                elem: '#between'
                ,range: true
            });
            Load(1);
            // 成功回调
              table.render({
                elem: '#safe'
                ,data:res.data
                ,cellMinWidth: 80
                ,page:{theme: '#1E9FFF'} 
                ,cols: [[
                  {field:'birthday',  title: '日期'}
                  ,{field:'rate',  title: '在线时长'}
                  ,{field:'price',  title: '违章次数'}
                  ,{field:'address',  title: '用户投诉数'}
                ]]
              });
            }).fail(function(err) {
            // 失败回调
            Load(1)
            console.log(err)
            Err('请求失败')
            });
        }else{
            Err('无数据')
        }
      } else if (data.index == 2) {
        Load();
        ajax(api.order.list,data2,'post').done(function(res) {
            console.log(res)
            // 日期区间
            laydate.render({
                elem: '#between2'
                ,range: true
            });
            Load(1);
            // 成功回调
              table.render({
                elem: '#order'
                ,data:res.data
                ,cellMinWidth: 80
                ,page:{theme: '#1E9FFF'} 
                ,cols: [[
                  {field:'order_no',  title: '订单号',minWidth:215}
                  ,{field:'apply_time',  title: '申请时间',minWidth:170}
                  ,{field:'orders_time',  title: '接单时间',minWidth:170}
                  ,{field:'passenger_name',  title: '乘客'}
                  ,{field:'fee',  title: '里程',templet:'<div>{{d.fee.meter?d.fee.meter:"-"}}</div>'}
                  ,{field:'ride_time',  title: '乘车时间',minWidth:170}
                  // ,{field:'complete_time',  title: '完成时间',minWidth:170}
                  ,{field:'fee',  title: '车费',templet:'<div>{{d.fee.passenger_money?d.fee.passenger_money:"-"}}</div>'}
                  ,{field:'order_state',  title: '支付状态',minWidth:90,templet:'<div>{{d.order_state==10||11?"已支付":"未支付"}}</div>'}
                  ,{field:'fee',  title: '师傅收入',minWidth:90,templet:'<div>{{d.fee.driver_money?d.fee.driver_money:"-"}}</div>'}
                ]]
              });
            }).fail(function(err) {
            // 失败回调
            Load(1)
            console.log(err)
            Err('请求失败')
            });
      }
    });
  });